home *** CD-ROM | disk | FTP | other *** search
/ InterCD 2000 September / september_2000.iso / intercd / root / ^Linux / Jooky / loaddir.c < prev    next >
Encoding:
C/C++ Source or Header  |  1999-11-01  |  797 b   |  48 lines

  1. #include "defines.h"
  2. #include "includes.h"
  3. #include "funcs.h"
  4.  
  5. int loaddir(int scram)
  6. {
  7.     if (loadandsortdir(scramble)==-1)
  8.     {
  9.         printf("Directory open failed");
  10.         removelockfile();
  11.         return -1;
  12.     }
  13.     count=0;
  14.     first=last=curr=NULL;
  15.  
  16.     for (qq=0;qq<numberoffiles;++qq)
  17.     {
  18.         if ((strcmp(sortedlist[qq]->d_name,".")!=0)&&
  19.             (strcmp(sortedlist[qq]->d_name,"..")!=0))
  20.         {
  21.             ++count;
  22.             if (first==NULL)
  23.                 curr=first=newchain();
  24.             else
  25.                 last=curr=append(curr);
  26.             strcpy(curr->fname,sortedlist[qq]->d_name);
  27.         }
  28.     }
  29.  
  30.     if (count==0)
  31.     {
  32.         fprintf(stderr,"No files found!\n");
  33.         return(-1);
  34.     }
  35.  
  36.     if (count==1)
  37.         last=first;
  38.  
  39.     /* make the line into a circle */
  40.  
  41.     first->prev = last ;
  42.     last->next = first ;
  43.     curr = last ;
  44.  
  45.     dirhasbeenloaded=1;
  46.     return 0;
  47. }
  48.